//
//  DuanXinYanZhengViewController.m
//  ShouKuang
//
//  Created by CodeYY on 2019/6/3.
//  Copyright © 2019 CodeYY. All rights reserved.
//

#import "DuanXinYanZhengViewController.h"

@interface DuanXinYanZhengViewController ()
@property(nonatomic, strong)UIImageView *tishiImg;
@property(nonatomic, strong)UILabel *tishiLab;
@property(nonatomic, weak)UIView *contentView;
@property(nonatomic, weak)UIButton *actionBtn;

@end

@implementation DuanXinYanZhengViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"短信验证";

    __weak typeof(self) weakSelf = self;
    UIView *contentView = [UIView new];
    contentView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview: contentView];
    _contentView = contentView;
    [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.offset(70);
        make.height.offset(400);
    }];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.equalTo(contentView.mas_bottom).offset(50);
        make.height.mas_equalTo(50);
    }];
    _actionBtn = btn;
    btn.backgroundColor = [UIColor whiteColor];
    [btn setTitle:@"返回商户号列表" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [[btn rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(id x) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    
    // 刷新UI
    [self refreshUI];
    // Do any additional setup after loading the view.
}

-(void)refreshUI
{
    NSInteger result = 1;
    if (result == 0) { // 短信验证失败
        self.tishiImg.image = [UIImage imageNamed:@"failure"];
        self.tishiLab.text = @"短信验证失败，\n请重新进行短信验证";
        
    }else if (result == 1){
        self.tishiImg.image = [UIImage imageNamed:@"success_red"];
        self.tishiLab.text = @"商户号添加成功，\n请在商户号列表中查看";
    }
}


-(UIImageView *)tishiImg
{
    if (!_tishiImg) {
        UIImageView *img = [UIImageView new];
        [self.contentView addSubview:img];
        [img mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.contentView.mas_centerY).offset(-20);
            make.centerX.offset(0);
        }];
        _tishiImg = img;
    }
    return _tishiImg;
}
-(UILabel *)tishiLab
{
    if (!_tishiLab) {
        UILabel *lab = [UILabel new];
        [self.contentView addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_centerY).offset(20);
            make.centerX.offset(0);
        }];
        _tishiLab = lab;
        lab.numberOfLines = 0;
        lab.textAlignment = NSTextAlignmentCenter;
        
    }
    return _tishiLab;
}


@end
